//
//  GSNewsMainCell.m
//  GameSky
//
//  Created by lanou on 16/1/10.
//  Copyright © 2016年 NiRongfei. All rights reserved.
//

#import "GSNewsMainCell.h"

#define kMargin 10

@implementation GSNewsMainCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 夜间模式
        self.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);
        
        [self setUp];
        
    }
    return self;
}

- (void)setUp
{
    self.coverImage = [[UIImageView alloc] init];
    [self.contentView addSubview:self.coverImage];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor grayColor]);
    [self.contentView addSubview:self.titleLabel];
    
    self.commentLabel = [[UILabel alloc] init];
    self.commentLabel.textAlignment = NSTextAlignmentRight;
    self.commentLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor grayColor]);
    self.commentLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.commentLabel];
    
    _titleLabel.sd_layout
    .topSpaceToView(self.contentView,kMargin)
    .rightSpaceToView(self.contentView,kMargin)
    .leftSpaceToView(self.contentView, 140)
    .autoHeightRatio(0);
    
    _coverImage.sd_layout
    .leftSpaceToView(self.contentView,kMargin)
    .topSpaceToView(self.contentView,kMargin)
    .rightSpaceToView(_titleLabel,kMargin)
    .heightIs(80);
    
    _commentLabel.sd_layout
    .rightSpaceToView(self.contentView,kMargin)
    .bottomEqualToView(_coverImage)
    .heightIs(20);
    
    [self setupAutoHeightWithBottomView:_coverImage bottomMargin:kMargin];
    
}


- (void)setModel:(GSNewsListModel *)model {
    _model = model;
    self.titleLabel.text = model.title;
    
    
    [self.coverImage sd_setImageWithURL:[NSURL URLWithString:model.thumbnailURLsArray.firstObject ] placeholderImage:kPHImage];
    self.commentLabel.text = [NSString stringWithFormat:@"%@评论",model.commentsCount];
}




@end
